<template>
  <el-row class="row">
    <el-row>
      <el-col :span="24">
        <el-col :span="12">
          <el-page-header @back="goBack" content="审核学生"></el-page-header>
        </el-col>
      </el-col>
    </el-row>
    <el-divider></el-divider>
    <el-row>
      <el-col :span="24" style="margin-bottom: 20px">
        <el-button size="medium" type="primary" @click="agree('1')" style="float: left">同&nbsp;&nbsp;意</el-button>
        <el-button size="medium" type="danger" @click="agree('2')" style="float: right">拒&nbsp;&nbsp;绝</el-button>
      </el-col>
    </el-row>
    <el-col :span="24">
      <el-table :data="tableData.filter(data => data.studentSelection.state=='0')" tooltip-effect="dark" border
                @selection-change="handleSelectionChange"
                style="width: 100%" v-loading="tableData2Load">
        <el-table-column type="selection" width="55"></el-table-column>
        <el-table-column prop="student.student.studentId" align="center" label="学号" width=""></el-table-column>
        <el-table-column prop="student.student.name" align="center" label="姓名" width=""></el-table-column>
        <el-table-column prop="student.colName" align="center" label="学院" width=""></el-table-column>
        <el-table-column align="center" label="班级" width="">
          <template slot-scope="scope">
            <span>{{scope.row.student.majorName.substr(0,2)+scope.row.student.className}}班</span>
          </template>
        </el-table-column>
        <el-table-column prop="studentSelection.titleType" align="center" label="毕设方向" width=""></el-table-column>
        <el-table-column prop="studentSelection.title" align="center" label="项目题目" width=""></el-table-column>
        <!--        <el-table-column align="center" label="审核" width="">-->
        <!--          <template slot-scope="scope">-->
        <!--            <el-button size="mini" type="primary" @click="CheckTaskBtn(scope.$index, scope.row)">同意</el-button>-->
        <!--            <el-button size="mini" type="danger" @click="CheckTaskBtn(scope.$index, scope.row)">拒绝</el-button>-->
        <!--          </template>-->
        <!--        </el-table-column>-->
      </el-table>
    </el-col>
  </el-row>
</template>

<script>
    export default {
        name: "CheckStudent",
        data() {
            return {
                tableData2Load: false,
                userinfo: this.UserInfo.getUserInfo(),
                dialogImageUrl: '',
                dialogVisible: false,
                disabled: false,
                form: {},
                tableData: [],
                multipleSelection: []
            }
        },
        methods: {
            goBack() {
                console.log('go back');
                this.$router.go(-1);//返回上一层
            },
            handleSelectionChange(val) {
                this.multipleSelection = val;
                console.log(val);
            }, reject() {
            }, agree(str) {
                var self = this;
                self.tableData2Load = true;
                if (self.multipleSelection.length == 0) {
                    self.MyMessage("请选择", "warning");
                    self.tableData2Load = false;
                } else {
                    console.log(self.multipleSelection)
                    var idList = new Array();
                    self.multipleSelection.forEach(re => {
                        idList.push(re.studentSelection.id);
                    });
                    self.$http.post(self.URL.api + 'studentSelection/update',
                        self.qs.stringify({"ssId": idList, "status": str}))
                        .then(function (response) {
                            console.log(response.data)
                            self.getTableData()
                        })
                        .catch(function (error) {
                            console.log(error)
                        });
                }
            },
            getTableData() {
                var self = this;
                self.tableData2Load = true;
                self.$http.post(self.URL.api + 'studentSelection/teaSel2',
                    self.qs.stringify({teaId: self.userinfo.id}))
                    .then(function (response) {
                        console.log(response.data)
                        if (response.data.flag) {
                            console.log(response.data.data)
                            self.tableData = response.data.data;
                            self.tableData2Load = false;
                        }
                        self.tableData2Load = false;
                    })
                    .catch(function (error) {
                        self.tableData2Load = false;
                        console.log("加载11111", error)
                    });
            },
            MyMessage(msg, type) {
                this.$message({
                    message: msg,
                    type: type
                });
            },
        }, mounted() {
            this.getTableData();
            // birthday: "1999-10-10T16:00:00.000+0000"
            // college: "1"
            // education: "本科"
            // email: null
            // faceIcon: "http://119.23.29.217/M00/00/07/rBETkV3U5X2AMQRbAAYDc_tpnFU023.png"
            // hiredate: "2017-08-31T16:00:00.000+0000"
            // id: "1195999384584642560"
            // jobNumber: "511923199808208433"
            // phone: "13568493830"
            // qq: null
            // remarks: ""
            // sex: "男"
            // state: "1"
            // teaname: "苟学成"
            // titles: "副教授"
            // uid: "1195999384588836864"
            console.log(this.userinfo)
        }
    }
</script>

<style scoped>

</style>
